<?php
/**
 * @link http://www.tintsoft.com/
 * @copyright Copyright (c) 2013 TintSoft LLC
 * @license http://www.tintsoft.com/license/
 */
namespace Leaps\Helper;

use Michelf\MarkdownExtra;

/**
 * BaseMarkdown 提供[[Markdown]]具体的实现
 * 不要使用 BaseMarkdown. 使用 [[Markdown]]
 *
 * @author Tongle Xu <xutongle@gmail.com>
 * @since 5.0
 */
class BaseMarkdown
{
    /**
     * @var MarkdownExtra
     */
    protected static $markdown;

    /**
     * 转化 markdown 成HTML
     *
     * @param string $content
     * @param array $config
     * @return string
     */
    public static function process($content, $config = [])
    {
        if (static::$markdown === null) {
            static::$markdown = new MarkdownExtra();
        }
        foreach ($config as $name => $value) {
            static::$markdown->{$name} = $value;
        }
        return static::$markdown->transform($content);
    }
}
